package com.ruoyi.residents.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.pojo.TbFloor;
import com.ruoyi.pojo.TbResidents;
import com.ruoyi.pojo.TbResidentsFloor;
import com.ruoyi.residents.dto.TbResidentsDTO;
import com.ruoyi.residents.mapper.TbResidentsFloorMapper;
import com.ruoyi.residents.mapper.TbResidentsMapper;
import com.ruoyi.residents.service.TbResidentsService;
import com.ruoyi.residents.vo.TbResidentsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbResidentsServiceImpl extends ServiceImpl<TbResidentsMapper, TbResidents> implements TbResidentsService {

    @Autowired
    private TbResidentsMapper tbResidentsMapper;

    @Override
    public Page<TbResidents> findList(Integer pageNum, Integer pageSize, TbResidentsVO tbResidentsVO) {

        Page<TbResidents> page = new Page<>(pageNum, pageSize);

        return tbResidentsMapper.findList(page,tbResidentsVO);
    }

    @Override
    public void updateAppUsageStatus(TbResidents tbResidents) {
        Integer appUsageStatus = tbResidents.getAppUsageStatus();
        if (appUsageStatus==1){
            tbResidents.setAppUsageStatus(2);
            tbResidentsMapper.updateById(tbResidents);
        }else {
            tbResidents.setAppUsageStatus(1);
            tbResidentsMapper.updateById(tbResidents);
        }

    }
}
